<template>
	<view>
		<view class="search_main">
			<view class="search_view">
				<u-search @clear="$initPage" @custom="$initPage" @search="$initPage" class="search_input" :height="58" placeholder="请输入关键词" v-model="inputName"></u-search>
			</view>
		</view>
		<recom-list :dataList="dataList" @changeFavorite="changeFavorite"></recom-list>

		<sww-load-more :params="dataListParams"></sww-load-more>
	</view>
</template>

<script>
import { pagingMixin } from '@/mixins/pagingMixin.js';
import recomList from '../components/recom-list/index.vue';
export default {
	mixins: [pagingMixin],
	components: {
		'recom-list': recomList
	},
	data() {
		return {
			inputName: ''
		};
	},
	onLoad() {
		this.$initPage();
	},
	onReachBottom() {
		this._load_data();
	},
	methods: {
		$initPage() {
			let params = {
				business_id: 1000,
				type: 1
			};
			if (this.inputName) {
				params.name = this.inputName;
			}
			this._init_data('GetProductPoolList', params);
		},
		changeFavorite (item){
			this.dataList[item.index].isFavorite = item.isFavorite == 1?0:1
		}
	}
};
</script>

<style scoped lang="scss">
.search_main {
	height: 80rpx;
	.search_view {
		box-sizing: border-box;
		position: fixed;
		top: 0;
		width: 100%;
		left: 0;
		z-index: 10;
		background: #fff;
		padding: 0 10rpx 0 30rpx;
		display: flex;
		align-items: center;
		height: 80rpx;
		.search_input {
			flex: 1;
			overflow: hidden;
		}
	}
}

</style>
